import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: localStorage.getItem('state') ? JSON.parse(localStorage.getItem('state')):{
    selectedKeys: [""],
    user: {},
    menuList:[],
    isSuper:"否"
  },
  mutations: {
    addSelectedKeys (state, value) {
      state.selectedKeys = value     // 重新给全局变量赋值，state是store中的state对象，value是传入的值
      localStorage.setItem("selectedKeys", JSON.stringify(value))
    },
    addUser (state, value) {
      state.user = value     // 重新给全局变量赋值，state是store中的state对象，value是传入的值
      localStorage.setItem("user", JSON.stringify(value))
    },
    changeMenuList (state, value) {
      state.menuList = value     // 重新给全局变量赋值，state是store中的state对象，value是传入的值
      localStorage.setItem("menuList", JSON.stringify(value))
    },
  },
  actions: {
  },
  modules: {
  }
})
